﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Maticsoft.Web
{
    public class PageBaseMember : System.Web.UI.Page
    {
        protected string UserId = string.Empty;
        protected string ManagerName = string.Empty;
        protected string GroupId = string.Empty;
        protected string LevelId = string.Empty;

        public PageBaseMember()
        { }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (!this.DesignMode)
            {
                if (System.Web.HttpContext.Current.Session != null)
                {
                    if (Session["UserId"] != null && Session["ManagerName"] != null && Session["LevelId"] != null && Session["GroupId"] != null)
                    {
                        UserId = Session["UserId"].ToString();
                        ManagerName = Session["ManagerName"].ToString();
                        LevelId = Session["LevelId"].ToString();
                        GroupId = Session["GroupId"].ToString();
                    }
                }
            }
        }
        /// <summary>
        /// 权限控制（是否为登陆用户）
        /// </summary>
        protected void Check()
        {
            if (string.IsNullOrEmpty(UserId) || string.IsNullOrEmpty(ManagerName) || string.IsNullOrEmpty(GroupId) || string.IsNullOrEmpty(LevelId))
            {
                Response.Redirect("Login.aspx?retUrl=" + HttpUtility.UrlEncode(Request.Url.ToString()));
            }
        }
    }
}